﻿using System;
using System.Collections.Generic;
using System.Text;
using UnityEngine.UI;
using UnityEngine;

/// <summary>
/// 游戏启动状态
/// </summary>
public class StartState:ISceneState
{
    // 初始化
    public StartState(SceneStateController controller):base("01StartScene",controller)
    {
    }

    private Image mLogo;
    private float mSmoothingSpeed = 1;
    private float mWaitTime = 2;
    
    /// <summary>
    /// 进入状态时调用
    /// </summary>
    public override void StateStart()
    {
        mLogo = GameObject.Find("Logo").GetComponent<Image>();
        mLogo.color = Color.black;
    }

    /// <summary>
    /// 更新状态时调用
    /// </summary>
    public override void StateUpdate()
    {
        // 颜色渐变
        mLogo.color = Color.Lerp(mLogo.color, Color.white, mSmoothingSpeed * Time.deltaTime);
        mWaitTime -= Time.deltaTime;
        
        // 倒计时结束，改变状态
        if (mWaitTime <= 0)
        {
            mController.SetState(new MainMenuState(mController));
        }
    }
}

